import { defineStore } from 'pinia'
const useUserStore = defineStore('user', {
  state: () => {
    return {
      showLoginDialog: false,
      token: '',
      currentProvider: {},
      userInfo: {}
    }
  },
  actions: {
    setState(params) {
      for (let key in params) {
        this[key] = params[key]
      }
    }
  },
  // persist: true // 默认本地localstorage
  persist: {
    key: 'game-user',
    storage: localStorage, // localStorage
    paths: ['token', 'userInfo', 'currentProvider'] // 空数组是都不存储，null或undefined时为存储所有，填写值时存储当前值
  }
})

export default useUserStore
